package tetris.client.stub;

final class Client
{
    private static String teamName = "Team 127"; // The Untouchables
    private static String teamPassword = "333typsy";
    private static String matchToken;
    private static String hostName;
    
	public static void main(String[] args)
	{
	    if(args.length < 2)
	    {
            Client.printHelp();
        }
	    else
	    {
	        matchToken = args[0];
	        hostName = args[1];
	        
	        Communication.setHostName(hostName);
	        
	        new Client();
	    }
	}

	public Client()
	{
		System.out.println("Starting Battle Tetris Client...");

		Command command = new Command();

		// retrieve the command to connect to the server
		String connectCommand = command.getMatchConnectCommand(teamName, matchToken, teamPassword);

		// retrieve the communication singleton
		Communication comm = Communication.getInstance();
		comm.setSubscription(matchToken);

		// send the command to connect to the server
		System.out.println("Connecting to server...");
		String clientToken = comm.send(connectCommand, Command.Key.CLIENT_TOKEN);
		System.out.println("Received client token... " + clientToken);

		// the GameInfo object will hold the client's name, token, game type, etc.
		GameInfo gameInfo = new GameInfo(clientToken, teamName);
		
		///
		/// ADD ALGORITHM
		System.out.println("Missing algorithm...");
		///

		System.out.println("Exiting...");
	}

	public static void printHelp()
	{
			System.out.println("usage: Client <match-token> <host-name>");
	}
}
